import request from '../request'
import type { ApiResponse } from '../types'

// 订单商品信息接口
export interface OrderGoodsInfo {
  goodsId: string
  title: string
  manufacturer: string
  spec: string
  midpack: number
  unit: string
}

// 订单商品项接口
export interface OrderGoodsItem {
  goodsId: string
  count: number
  discountPrice: number | string
  price: number | string
  isComment: number
  remark: string
  goodsInfo: any
}

// 创建订单请求参数接口
export interface CreateOrderParams {
  goodsList: OrderGoodsItem[]
  remark: string
  title: string
  isNextValPrice: boolean
}

// 创建订单响应接口
export interface CreateOrderResponse {
  orderId: string
  orderNo: string
}

// 删除订单商品请求参数接口
export interface DeleteOrderGoodsParams {
  orderNum: string
  goodsId: string
}

// 删除订单请求参数接口
export interface DeleteOrderParams {
  orderNum: string
}

// 创建订单
export function createOrder(data: CreateOrderParams): Promise<ApiResponse<CreateOrderResponse>> {
  return request.post('/app/order/info/create', data)
}

// 删除订单中的商品
export function deleteOrderGoods(data: DeleteOrderGoodsParams): Promise<ApiResponse> {
  return request.post('/app/order/info/deleteOrderGoods', data)
}

// 删除整个订单
export function deleteOrder(data: DeleteOrderParams): Promise<ApiResponse> {
  return request.post('/app/order/info/deleteOrder', data)
} 